package bb.lanxing.lib.devices.bryton.bbcp;

import androidx.exifinterface.media.ExifInterface;
import java.util.TreeMap;

public class AlarmSettings {
    private TreeMap<String, String> settings;

    public boolean setSmartAlarm(boolean z, String[] strArr) {
        if (strArr.length != 3) {
            return false;
        }
        putInMap(z, strArr, ExifInterface.GPS_MEASUREMENT_IN_PROGRESS);
        return true;
    }

    public boolean setNodAlarm(boolean z, String[] strArr) {
        if (strArr.length != 2) {
            return false;
        }
        putInMap(z, strArr, "B");
        return true;
    }

    public boolean setIdleAlert(boolean z, String[] strArr) {
        if (strArr.length != 3) {
            return false;
        }
        putInMap(z, strArr, "C");
        return true;
    }

    public byte[] getBbcpData() throws BbcpValidationException {
        return BbcpData.packAsciiPayload(this.settings);
    }

    private void putInMap(boolean z, String[] strArr, String str) {
        if (z) {
            TreeMap<String, String> treeMap = this.settings;
            treeMap.put(str + "0", "1");
        } else {
            TreeMap<String, String> treeMap2 = this.settings;
            treeMap2.put(str + "0", "0");
        }
        int i = 0;
        while (i < strArr.length) {
            TreeMap<String, String> treeMap3 = this.settings;
            StringBuilder sb = new StringBuilder();
            sb.append(str);
            int i2 = i + 1;
            sb.append(i2);
            treeMap3.put(sb.toString(), strArr[i]);
            i = i2;
        }
    }
}
